﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Engine.Dtd.Schema;
using System.IO;
using Engine.Sgml.Validation;
using System.Diagnostics;
using Engine.Sgml.Matching;

namespace Engine.Sgml.Test {
    /// <summary>
    /// Summary description for SgmlValidatorFixture
    /// </summary>
    [TestClass]
    public class SgmlValidatorTest {
        public SgmlValidatorTest() {
            //
            // TODO: Add constructor logic here
            //
            }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext {
            get {
                return testContextInstance;
                }
            set {
                testContextInstance = value;
                }
            }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        [TestInitialize()]
        public void MyTestInitialize() {
            DirectoryInfo fileDirectory = Directory.GetParent(TestContext.TestDir).Parent;

            DirectoryInfo schemaDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Scheme Samples"));
            DirectoryInfo saveDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Saved Docs"));
            fileDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Document Samples"));

            Assert.IsTrue(schemaDirectory.Exists);
            Assert.IsTrue(fileDirectory.Exists);
            Assert.IsTrue(saveDirectory.Exists);

            schemaDir = schemaDirectory.FullName;
            fileDir = fileDirectory.FullName;
            }

        public void InitializeForMain() {
            DirectoryInfo fileDirectory = Directory.GetParent(Directory.GetCurrentDirectory());
            fileDirectory = fileDirectory.Parent.Parent;

            DirectoryInfo schemaDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Scheme Samples"));
            DirectoryInfo saveDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Saved Docs"));
            fileDirectory = new DirectoryInfo(Path.Combine(fileDirectory.FullName, @"Engine.Sgml.Test\Document Samples"));

            schemaDir = schemaDirectory.FullName;
            fileDir = fileDirectory.FullName;
            }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        private string schemaDir;
        private string fileDir;

        private Uri ResolveFileUrl(string fileName) {
            return new Uri(string.Format("file://{0}", Path.Combine(fileDir, fileName)));
            }

        private Uri ResolveSchemaUrl(string fileName) {
            return new Uri(string.Format("file://{0}", Path.Combine(schemaDir, fileName)));
            }

        [TestMethod]
        public void ReadResume() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Resume.dtd")), "resume");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine(fileDir, "Validator Resume.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();
            }

        [TestMethod]
        public void ReadResume001() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Resume.dtd")), "resume");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine(fileDir, "Validator Bad Resume 001.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement name = doc.SelectElement(".//name");
            Assert.IsNotNull(name);
            Assert.IsNull(name.SelectElement("following-sibling::name"));
            Assert.IsTrue(name.Elements().ElementAt(0).LocalName == "firstName");
            Assert.IsTrue(name.Elements().ElementAt(1).LocalName == "nickName");
            Assert.IsTrue(name.Elements().ElementAt(2).LocalName == "lastName");
            Assert.IsTrue(name.Nodes.GetOrDefault(3) == null);
            }

        [TestMethod]
        public void ReadResume002() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Resume.dtd")), "resume");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine(fileDir, "Validator Bad Resume 002.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement name = doc.SelectElement(".//name");
            Assert.IsNotNull(name);
            Assert.IsNull(name.SelectElement("following-sibling::name"));
            Assert.IsTrue(name.Elements().ElementAt(0).LocalName == "firstName");
            Assert.IsTrue(name.Elements().ElementAt(1).LocalName == "nickName");
            Assert.IsTrue(name.Elements().ElementAt(2).LocalName == "middleInitial");
            Assert.IsTrue(name.Elements().ElementAt(3).LocalName == "lastName");
            }

        [TestMethod]
        public void ReadResume003() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Resume.dtd")), "resume");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine(fileDir, "Validator Bad Resume 003.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement name = doc.SelectElement(".//name");
            Assert.IsNotNull(name);
            Assert.IsNull(name.SelectElement("following-sibling::name"));
            Assert.IsTrue(name.Elements().ElementAt(0).LocalName == "firstName");
            Assert.IsTrue(name.Elements().ElementAt(1).LocalName == "nickName");
            Assert.IsTrue(name.Elements().ElementAt(2).LocalName == "lastName");
            }

        [TestMethod]
        public void ReadResume004() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Resume.dtd")), "resume");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine(fileDir, "Validator Bad Resume 004.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement location = doc.SelectElement(".//location");
            Assert.IsNotNull(location);
            Assert.IsTrue(location.Elements().ElementAt(0).LocalName == "street");
            Assert.IsTrue(location.Elements().ElementAt(1).LocalName == "suite");
            Assert.IsTrue(location.Elements().ElementAt(2).LocalName == "city");
            Assert.IsTrue(location.Elements().ElementAt(3).LocalName == "state");
            Assert.IsTrue(location.Elements().ElementAt(4).LocalName == "zip");
            }

        [TestMethod]
        public void ReadTegs() {
            SgmlDocument doc = new SgmlDocument();
            doc.ValidatorBehavior.DtdDisabled = true;

            doc.Load(new Uri(Path.Combine(fileDir, "Tag HTML 001.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            Assert.IsTrue(6 == doc.SelectElements(".//input").Count());
            Assert.IsNotNull(doc.SelectElement("FORM/input[1][@name = 'button']"));
            Assert.IsNotNull(doc.SelectElement("FORM/input[2][@type = 'button']"));
            Assert.IsNotNull(doc.SelectElement("FORM/input[3][@name = 'button']"));
            Assert.IsNotNull(doc.SelectElement("FORM/input[4][@name = 'but/=ton']"));
            Assert.IsNotNull(doc.SelectElement("FORM/input[5][@type = 'button' and @on]"));
            SElement element = doc.SelectElement(@"FORM/input[6][@name]");
            Assert.IsNotNull(element);
            Assert.AreEqual<string>("button />\n  <input type=", element.Attribute("name"));
            }

        [TestMethod]
        public void ReadBudAttribute() {
            SgmlDocument document = new SgmlDocument();
            document.ValidatorBehavior.DtdDisabled = true;
            MemoryStream reader = new MemoryStream(Encoding.UTF8.GetBytes("<sgml attr=-//TEST//TEST SGML//EN>"));
            document.Load(reader);
            string content = document.ToString();

            reader = new MemoryStream(Encoding.UTF8.GetBytes("<sgml attr='-//TEST//TEST SGML//EN'>"));
            document.Load(reader);

            content = document.ToString();
            }

        [TestMethod]
        public void ReadSpecialEntity() {
            SgmlDocument document = new SgmlDocument();
            MemoryStream reader = new MemoryStream(Encoding.UTF8.GetBytes(@"I have some 'bad' behavior with SGMLReader not being able to parse a html description that contains special entities (more specifically in this case it is &quot;&#56256;&quot;)."));
            document.Load(reader);
            string content = document.ToString();
            }

        [TestMethod]
        public void ReadDoctypeTags() {
            SgmlDocument doc = new SgmlDocument();
            doc.ValidatorBehavior.DtdDisabled = true;

            doc.Load(new Uri(Path.Combine(fileDir, "Tag HTML 002.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();
            }

        [TestMethod]
        public void ReadDoctypeWithSubsetTags() {
            SgmlDocument doc = new SgmlDocument();
            doc.ValidatorBehavior.DtdDisabled = true;

            doc.Load(new Uri(Path.Combine(fileDir, "Tag HTML 003.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();
            }

        [TestMethod]
        public void ReadAnthology001() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 001.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology002() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 002.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology003() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 003.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology004() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 004.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology005() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 005.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology006() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 006.xml")));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher modelMatch = new ModelMatcher();

            SElement element = doc.SelectElement(".//poem");
            Assert.IsNotNull(element);

            IList<Capture> match = modelMatch.Match(element);

            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));

            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology007() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument();

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 007.xml")), schema);
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        [TestMethod]
        public void ReadAnthology008() {
            DtdSchema schema = DtdSchema.Load(new Uri(Path.Combine(schemaDir, "Anthology.dtd")), "ANTHOLOGY");
            SgmlDocument doc = new SgmlDocument(schema);

            doc.Load(new Uri(Path.Combine("file://", this.fileDir, "Validator Anthology 008.xml")));
            string content = doc.ToString();
            VerifyAnthology(doc);
            }

        private static void VerifyAnthology(SgmlDocument doc) {
            IEnumerable<SElement> poems = doc.SelectElements("anthology/poem");
            foreach (SElement poem in poems) {
                SElement element = poem.FirstNode;
                Assert.IsNotNull(element);
            Loop:
                if (element.LocalName.Equals("line", StringComparison.OrdinalIgnoreCase)) {
                    int lineCount = 1;
                    element = element.NextNode;
                    while (element != null) {
                        Assert.IsTrue(element.LocalName.Equals("line", StringComparison.OrdinalIgnoreCase));
                        element = element.NextNode;
                        lineCount++;
                        }
                    Assert.IsTrue(lineCount == 3);
                    }
                else if (element.LocalName == "refrain") {
                    element = element.NextNode;
                    Assert.IsNotNull(element);
                    Assert.IsTrue(element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase));
                    element = element.NextNode;
                    Assert.IsNotNull(element);
                    if (element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase)) {
                        element = element.NextNode;
                        Assert.IsNotNull(element);
                        if (element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase)) {
                            do {
                                Assert.IsTrue(element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase));
                                element = element.NextNode;
                                } while (element != null && element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase));
                            }
                        if (element != null)
                            Assert.IsTrue(element.LocalName.Equals("refrain", StringComparison.OrdinalIgnoreCase));
                        }
                    else if (element.LocalName == "refrain") {
                        element = element.NextNode;
                        Assert.IsNotNull(element);
                        Assert.IsTrue(element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase));
                        }
                    else
                        Assert.Fail();
                    }
                else if (element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase)) {
                    element = element.NextNode;
                    if (element == null)
                        continue;
                    Assert.IsTrue(element.LocalName == "refrain");
                    element = element.NextNode;
                    Assert.IsNotNull(element);
                    Assert.IsTrue(element.LocalName.Equals("stanza", StringComparison.OrdinalIgnoreCase));
                    element = element.NextNode;
                    Assert.IsNotNull(element);
                    Assert.IsTrue(element.LocalName == "refrain");
                    }
                else if (element.LocalName == "title") {
                    element = element.NextNode;
                    Assert.IsNotNull(element);
                    goto Loop;
                    }
                else if (element.NodeType == SgmlNodeType.Comment) {
                    element = element.NextNode;
                    while (element != null && element.NodeType == SgmlNodeType.Comment) {
                        element = element.NextNode;
                        }
                    if (element != null)
                        goto Loop;
                    }
                else
                    Assert.Fail("The element '{0}' does't correspond to the content model.", element.LocalName);
                }
            }

        [TestMethod]
        public void ReadTable001() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 001.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable002() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 002.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable003() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 003.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable004() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 004.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable005() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 005.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable006() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 006.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable007() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 007.xml"));
            string content = doc.ToString();
            VerifyTable(doc);
            }

        [TestMethod]
        public void ReadTable008() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 008.xml"));
            string content = doc.ToString();

            SElement tr = doc.SelectElement("HTML/BODY/table/TBODY/tr");
            Assert.IsNotNull(tr);
            Assert.IsTrue(tr.Elements().Count() == 2);
            Assert.IsTrue(tr.Elements().ElementAt(0).LocalName == "th");
            Assert.IsTrue(doc.SelectElement("HTML/BODY").Elements().Count() == 1);
            }

        [TestMethod]
        public void ReadTable009() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 009.xml"));
            string content = doc.ToString();

            SElement table = doc.SelectElement("HTML/BODY/table");
            Assert.IsNotNull(table);
            ModelMatcher validator = new ModelMatcher();
            IList<Capture> match = validator.Match(table);
            Assert.IsTrue(match.All(m => m.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsNotNull(table);

            Assert.IsTrue(doc.SelectElement("HTML/BODY").Elements().Count() == 1);
            }

        [TestMethod]
        public void ReadTable0010() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 0010.xml"));
            string content = doc.ToString();
            }

        [TestMethod]
        public void ReadTable0011() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 0011.xml"));
            string content = doc.ToString();
            }

        [TestMethod]
        public void ReadTable0012() {
            SgmlDocument doc = new SgmlDocument();

            doc.Load(ResolveFileUrl("Validator Table 0012.xml"));
            string content = doc.ToString();
            }

        [TestMethod]
        public void ReadTable0013() {
            SgmlDocument doc = new SgmlDocument();
            // Build TR and surround two TD
            doc.Load(ResolveFileUrl("Validator Table 0013.xml"));
            string content = doc.ToString();
            }

        private static void VerifyTable(SgmlDocument doc) {
            IEnumerable<SElement> tables = doc.SelectElements("HTML/BODY/table");
            Assert.IsTrue(tables.Count() == 1);
            foreach (SElement table in tables) {
                Assert.IsTrue(table.FirstNode.LocalName == "caption");
                Assert.IsTrue(table.Elements().ElementAt(1).LocalName == "col");
                Assert.IsTrue(table.Elements().ElementAt(2).LocalName == "tfoot");
                Assert.IsTrue(table.Elements().ElementAt(3).LocalName == "tbody");
                Assert.IsTrue(table.Elements().ElementAt(4).LocalName == "tbody");
                }
            }

        [TestMethod]
        public void ReadContentModel001() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ContentModelFixture.dtd"), "fixture");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("Validator Content Model 001.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement fixture = doc.SelectElement("fixture");
            Assert.IsNotNull(fixture);

            Assert.IsTrue(fixture.Elements().First().LocalName == "middleName");
            Assert.IsTrue(fixture.Elements().ElementAt(1).LocalName == "middleInitial");
            Assert.IsTrue(fixture.Elements().ElementAt(2).LocalName == "nick");
            Assert.IsTrue(fixture.Elements().Last().LocalName == "code");
            }

        [TestMethod]
        public void ReadContentModel002() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("Schema Example 001.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("Validator Content Model 002.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            SElement element = doc.SelectElement("ELEMENT");

            Assert.IsNotNull(element);

            Assert.IsTrue(element.Nodes.First().LocalName == "ELEMENT_3");
            Assert.IsTrue(element.Nodes.ElementAt(1).LocalName == "ELEMENT_4");
            Assert.IsTrue(element.Nodes.ElementAt(2).LocalName == "ELEMENT_3");
            Assert.IsTrue(element.Nodes.Last().LocalName == "ELEMENT_4");
            }

        [TestMethod]
        public void ReadContentModel003() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ContextSchema001.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ContextDocument001.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            Debug.Print(content);

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel004() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ContextSchema002.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ContextDocument002.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel005() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("gkmmehqg.2st.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("gkmmehqg.2st.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel006() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("akgobzek.4ga.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("akgobzek.4ga.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel007() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("gtiw4a3e.hsz.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("gtiw4a3e.hsz.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }



        [TestMethod]
        public void ReadContentModel008() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("rdonjvtf.qnr.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("rdonjvtf.qnr.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel009() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("x5uwdph5.3te.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("x5uwdph5.3te.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel010() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("zdvqncnw.wn3.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("zdvqncnw.wn3.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel011() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("oqyetwx5.u4m.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("oqyetwx5.u4m.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel012() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("2h2l3gki.ald.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("2h2l3gki.ald.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel013() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("4ltswnu4.zo2.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("4ltswnu4.zo2.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel014() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("wqmwptti.dyu.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("wqmwptti.dyu.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel015() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("pixol3fs.lnw.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("pixol3fs.lnw.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        // 3hn3qpgn.20k.xml 
        [TestMethod]
        public void ReadContentModel016() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("3hn3qpgn.20k.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel017() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("3ag4nlkg.nvf.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel018() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("mnmjwazo.kxw.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        // 

        [TestMethod]
        public void ReadContentModel019() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ossh4l1g.m4i.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel020() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("c3jmrmjz.gbl.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        //wv4qwxdx.vdl.xml

        [TestMethod]
        public void ReadContentModel021() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("wv4qwxdx.vdl.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel022() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("up3wqy2a.vpy.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel023() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("uxbfgknh.rkd.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel024() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("2wuka3c1.rbm.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel025() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3hn3qpgn.20k.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("e30m3a2c.rp2.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel026() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("haybzais.mri.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("haybzais.mri.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel027() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("rro1qeod.yfg.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("rro1qeod.yfg.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadContentModel028() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("4hp5jkbv.ani.dtd"), "TABLE");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("4hp5jkbv.ani.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("TABLE");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme001() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("4eayhof5.bas.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("4eayhof5.bas.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme002() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("bzkd4ku2.cn1.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("bzkd4ku2.cn1.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        // ozr4zb3r.hf5.xml
        [TestMethod]
        public void ReadDocumentBasedOnScheme003() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ozr4zb3r.hf5.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ozr4zb3r.hf5.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        // 2f5t4f3f.air.dtd
        [TestMethod]
        public void ReadDocumentBasedOnScheme004() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("2f5t4f3f.air.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("2f5t4f3f.air.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme005() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3d0pidkn.iqx.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("3d0pidkn.iqx.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme006() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("q2nja1jl.nda.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("q2nja1jl.nda.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme007() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("zoyedzjl.404.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("zoyedzjl.404.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme008() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("zlf3ua53.fpi.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("zlf3ua53.fpi.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme009() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("5wsyiskp.xkg.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("5wsyiskp.xkg.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme010() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("jeujcvdx.zak.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("jeujcvdx.zak.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme011() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("3me2d20g.f55.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("3me2d20g.f55.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme012() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("jaulvekm.fwm.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("jaulvekm.fwm.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme013() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("emcz0nke.ifs.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("emcz0nke.ifs.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme014() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("xhnpubj0.qsv.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("xhnpubj0.qsv.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme015() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("sblmnrqy.b1p.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("sblmnrqy.b1p.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme016() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("fo0epfo4.vwu.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("fo0epfo4.vwu.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme017() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("qypzaeok.rkk.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("qypzaeok.rkk.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme018() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("v3ctmax1.r2n.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("v3ctmax1.r2n.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme019() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("uxawx4z5.5fg.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("uxawx4z5.5fg.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme020() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("z2h32xmb.s2h.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("z2h32xmb.s2h.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme021() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ma0lm0kz.3gc.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ma0lm0kz.3gc.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme022() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("wll2xiqu.ga4.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("wll2xiqu.ga4.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme023() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("vymjhi1f.lgr.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("vymjhi1f.lgr.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        public void PrepareTest(out SgmlDocument document) {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("vymjhi1f.lgr.dtd"), "ELEMENT");
            document = new SgmlDocument(schema);
            }

        public void RunPreparedTest(SgmlDocument document) {
            document.Load(ResolveFileUrl("vymjhi1f.lgr.xml"));

            string content = document.ToString();
            string xml = document.ToXml();
            }


        [TestMethod]
        public void ReadDocumentBasedOnScheme024() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("c1rc4ls1.qp4.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("c1rc4ls1.qp4.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }


        [TestMethod]
        public void ReadDocumentBasedOnScheme025() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("l0h4ntk2.xww.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("l0h4ntk2.xww.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme026() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("njzmwbzh.rsi.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("njzmwbzh.rsi.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme027() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("1xxbzwcc.yhz.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("1xxbzwcc.yhz.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme028() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("wd3os5ct.o4f.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("wd3os5ct.o4f.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme029() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("bv31pmbh.nuw.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("bv31pmbh.nuw.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme030() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("r5ahk5hk.ppx.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("r5ahk5hk.ppx.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme031() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("0jagitkc.yyn.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("0jagitkc.yyn.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme032() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("vjgwr2qa.xcr.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("vjgwr2qa.xcr.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme033() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("icpfuytx.icp.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("icpfuytx.icp.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme034() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("x1a5w0ga.0gy.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("x1a5w0ga.0gy.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme035() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("ahvoav1k.bza.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("ahvoav1k.bza.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme036() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("lun5ls42.r1t.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("lun5ls42.r1t.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme037() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("m3vlunyr.gmn.dtd"), "ELEMENT");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("m3vlunyr.gmn.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            SElement element = doc.SelectElement("ELEMENT");
            Assert.IsNotNull(element);
            IList<Capture> match = matcher.Match(element);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == element.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnResumeScheme001() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("mnjwamol.bg0.dtd"), "resume");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("mnjwamol.bg0.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            IList<Capture> match = matcher.Match(doc.Root.FirstNode);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == doc.Root.FirstNode.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnResumeScheme002() {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl("xhvpcpyw.eaq.dtd"), "resume");
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl("xhvpcpyw.eaq.xml"));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            IList<Capture> match = matcher.Match(doc.Root.FirstNode);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == doc.Root.FirstNode.Nodes.Count);
            }

        [TestMethod]
        public void ReadDocumentBasedOnAnthologyScheme001() {
            ReadDocumentBasedOnSchema("aq3is54q.anp", "ANTHOLOGY");
            }

        [TestMethod]
        public void ReadDocumentBasedOnAnthologyScheme002() {
            ReadDocumentBasedOnSchema("k35gmc0i.5bs", "ANTHOLOGY");
            }

        [TestMethod]
        public void ReadDocumentBasedOnScheme042() {
            ReadDocumentBasedOnSchema("0013mufq.kbt", "ELEMENT");
            }

        public void ReadDocumentBasedOnSchema(string fileName, string schemaName) {
            DtdSchema schema = DtdSchema.Load(ResolveSchemaUrl(string.Format("{0}.dtd", fileName)), schemaName);
            SgmlDocument doc = new SgmlDocument(schema);


            doc.Load(ResolveFileUrl(string.Format("{0}.xml", fileName)));

            string content = doc.ToString();
            string xml = doc.ToXml();

            ModelMatcher matcher = new ModelMatcher();
            IList<Capture> match = matcher.Match(doc.Root.FirstNode);
            Assert.IsTrue(match.All(c => c.Entity.Match.Type == AccordanceTypes.Full));
            Assert.IsTrue(match.Last().EndIndex + 1 == doc.Root.FirstNode.Nodes.Count);
            }
        }
    }
